package dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import model.EventType;
import utils.JdbcUtil;

public class EventTypeDao {
	public List<EventType> getEventTypeList(){
		Connection con =null;  
        PreparedStatement pstmt = null;  
        ResultSet rs = null;
		
		List<EventType> etList = null;
		try {
			con = JdbcUtil.getCon();
			String sql = "select * from t_eventType";
				etList = new ArrayList<EventType>();
				 pstmt = con.prepareStatement(sql);
				 rs = pstmt.executeQuery();
				while(rs.next()){
					EventType et = new EventType();
					et.setId(rs.getInt("id"));
					et.setTypeName(rs.getString("typeName"));
					etList.add(et);
				}
		} catch (Exception e) {
			e.printStackTrace();
		}finally{
			JdbcUtil.closeAll(rs, pstmt,con);
		}	
		return etList;
	}
}
